package com.sky.mapper;

import com.sky.dto.EmployeePageQueryDTO;
import com.sky.entity.Employee;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    /**
     * 根据用户名查询员工
     */
    @Select("select * from employee where username = #{username}")
    Employee getByUsername(String username);

    /**
     * 查询所有员工
     */
    List<Employee> selectAll(EmployeePageQueryDTO employeePageQueryDTO);

    /**
     * 新增员工
     */
    void insert(Employee employee);

    /**
     * 根据id查询员工（查询回显）
     */
    @Select("select * from employee where id = #{id}")
    Employee selectById(Long id);

    /**
     * 修改员工
     */
    void update(Employee employee);

    /**
     * 修改员工状态
     */
    @Select("update employee set status = #{status}, update_time = #{updateTime}, update_user = #{updateUser} where id = #{id}")
    void updateStatus(Employee employee);
}
